home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 September
/
Macworld (1998-09).dmg
/
Shareware World
/
Info
/
For Developers
/
MacZoop 1.8.3
/
Required Classes
/
Z Headers
/
ZWindow.h
< prev
next >
Wrap
Text File
|
1998-07-06
|
8KB
|
253 lines
/*************************************************************************************************
*
*
* MacZoop - "the framework for the rest of us"
*
*
*
* ZWindow.h -- the window object
*
*
*
*
*
* © 1996, Graham Cox
*
*
*
*
*************************************************************************************************/
#pragma once
#ifndef __ZWINDOW__
#define __ZWINDOW__
#ifndef __ZCOMMANDER__
#include "ZCommander.h"
#endif
class ZUndoTask;
class ZWindowManager;
#include "ProjectSettings.h"
#include <drag.h>
#if _USE_NAVIGATION_SERVICES
#include <Navigation.h>
extern NavEventUPP gNavEventHandler;
#endif
// set up streaming stuff:
DEFINECLASSID( ZWindow, 'zwin' );
// class definition:
class ZWindow : public ZCommander
{
friend class ZWindowManager;
protected:
Rect sizeRect; // min and max sizes for window
WindowPtr macWindow; // the mac window associated with this object
short windID; // res ID of 'WIND' template
Boolean dirty; // TRUE if window needs to be saved
Boolean isNamed; // TRUE if window has a name other than "untitled"
Boolean stationeryFile; // TRUE if file opened was stationery (template)
FSSpec macFile; // the file that corresponds to this window
OSType macFType; // file type last opened
Boolean printable; // TRUE if this window can be printed (default FALSE)
Boolean isPrinting; // TRUE if draw operation is to printer
Boolean floating; // TRUE if this is a floating window
Boolean disableAutoClose; // if TRUE, this window is skipped during Quit or Close All
Rect zoomSource; // global rect where window was zoomed from
public:
ZWindow( ZCommander* aBoss, const short windowID );
ZWindow();
virtual ~ZWindow();
// initialisation (MUST be called after construction)
virtual void InitZWindow();
// drawing and clicking
virtual void Focus();
virtual void Draw();
virtual void DrawGrow();
virtual void DrawContent();
virtual void Click( const Point mouse, const short modifiers);
virtual void AdjustCursor( const Point mouse, const short modifiers);
virtual void PostRefresh();
virtual Boolean ClickInSamePlace( const Point click1, const Point click2 );
virtual void SetDefaultColours();
// top-level call to do an update
virtual void PerformUpdate();
// window state manipulation
virtual void Hide();
virtual void Show();
virtual void Select();
virtual void Activate();
virtual void Deactivate();
virtual Boolean Close( const short phase );
virtual Boolean CloseSubsidiaryWindows( const short phase );
// command handling
virtual void HandleCommand( const long aCmd );
virtual void HandleCommand( const short menuID, const short itemID );
virtual void UpdateMenus();
virtual void SetTask( ZUndoTask* aTask );
// sizing and zooming
virtual void SetSizeRect( const Rect& szRect );
virtual void GetSizeRect( Rect* szRect );
virtual void Zoom( const short partCode );
virtual void PlaceAt( const short hGlobal, const short vGlobal );
virtual void Place();
virtual void SetSize( const short width, const short height, const Boolean reDraw );
virtual void SetSize( const short width, const short height ) { SetSize(width, height, TRUE); };
virtual void SetStdZoomRect( const Rect& aRect );
virtual void SetUserZoomRect( const Rect& aRect );
virtual void GetIdealWindowZoomSize( Rect* idealSize );
virtual void WindowResized() {};
// file handling
virtual Boolean Save( const Boolean forceSaveAs = FALSE );
virtual void SaveFile();
virtual void Revert();
virtual void SetFile( const FSSpec& aFile );
virtual void OpenFile( const OSType aFileType, Boolean isStationery = FALSE );
virtual void PickFile( StandardFileReply* macReply );
#if _USE_NAVIGATION_SERVICES
virtual void PickFile( NavReplyRecord* navReply );
#endif
// print handling
virtual void CalcPages( const Rect& paperRect, short* pagesH, short* pagesV );
virtual void PrintOnePage( const short pageNum, const Rect& paperRect );
virtual void PrintingStarting() { isPrinting = TRUE; };
virtual void PrintingFinishing() { isPrinting = FALSE; };
inline Boolean IsPrintable() { return printable; };
// other info
virtual void SetTitle( Str255 aTitle );
virtual void GetName( Str255 name );
virtual void GetContentRect( Rect* contents );
virtual void GetBounds( Rect* aBounds ) { GetContentRect( aBounds ); };
virtual Boolean IsVisible();
virtual Boolean IsActive();
// positioning and frame info:
virtual short GetTitleBarHeight();
virtual void GetStructureRegion( RgnHandle aRgn );
virtual void GetContentRegion( RgnHandle aRgn );
virtual void GetStructureFrameBorder( Rect* aRect );
virtual void GetGlobalPosition( short* hGlobal, short* vGlobal );
// saving and restoring window position as resource in file or prefs:
virtual void SavePosition( short id = 0 );
virtual void RestorePosition( short id = 0 );
// various inline getters & setters
inline WindowPtr GetMacWindow(){ return macWindow; };
inline Boolean Floats() { return floating; };
inline Boolean NoAutoClose() { return disableAutoClose; };
inline void GetFileSpec( FSSpec* aSpec ) { *aSpec = macFile; };
inline Boolean IsDirty() { return dirty; };
inline void SetDirty( Boolean dState ) { dirty = dState; };
inline OSType GetFileType() { return macFType; };
// streaming:
virtual void WriteToStream( ZStream* aStream );
virtual void ReadFromStream( ZStream* aStream );
// drag and drop support:
virtual void Drag( const Point startPt );
virtual void Drop( const OSType flavour, const Ptr data, const long dataSize ) {};
virtual void DragHilite( const Boolean state, const DragReference theDrag );
virtual Boolean AcceptsFlavour( const OSType aFlavour ) { return TRUE; };
virtual RgnHandle MakeDragRgn();
virtual void MakeDragData( const DragReference theDrag ) {};
// lowest level d+d handlers:
virtual void DragDispatch( const DragTrackingMessage theMessage, const DragReference theDrag);
virtual void DropHandler( const DragReference theDrag );
protected:
// d+d installers
virtual void InstallDragHandlers();
virtual void RemoveDragHandlers();
// tracking handler methods
virtual void EnteredHandler( const DragReference theDrag) {};
virtual void EnteredWindow( const DragReference theDrag);
virtual void InWindow( const DragReference theDrag) {};
virtual void LeftWindow( const DragReference theDrag);
virtual void LeftHandler( const DragReference theDrag) {};
// constructing mac windows:
virtual void MakeMacWindow( const short windID );
virtual void MakeMacWindow( Rect* aRect, Str255 title, Boolean visible = FALSE, short varCode = 0, Boolean hasCloseBox = FALSE, void* userData = NULL );
};
#define kNoFile -9999
#define kRevertConfirmAlertID 135
#define kMsgWindowClosing 'winz'
/*
ZWindows manage Mac windows. The refCon of a macWindow in Object MacZapp is the object
reference. This class handles all types of non-dialog windows. For dialogs, use ZDialog,
which is a subclass of this. A ZWindow is really equivalent to a document, since it has
methods for reading and writing its contents to files. However, you can ignore this
facility for non-document windows. This approach simplifies the framework, since you don't
need separate classes for different types of windows.
*/
#define kInfinityWindoidDefinition 128
// structure of "WIND' resource- we need to take a peek here ourselves to determine if the
// window is a floater or not
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
typedef struct
{
Rect bounds;
short procID;
short filler;
Boolean visible;
Boolean goAway;
long refCon;
Str255 title;
}
WindTemplate, *WindTemplatePtr, **WindTemplateHdl;
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#endif